package com.etcn.modules.busi.launch.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.etcn.common.annotation.QueryCache;
import com.etcn.common.service.impl.CrudServiceImpl;
import com.etcn.modules.busi.launch.dao.IWmStartimageConfigDao;
import com.etcn.modules.busi.launch.pojo.WmStartimageConfig;
import com.etcn.modules.busi.launch.service.IWmStartimageConfigService;

/**
 * 启动图serviceImpl
 * @author guozc
 * @date 2018-03-28 17:33:58
 */
 @Service("wmStartimageConfigService")
public class WmStartimageConfigServiceImpl extends CrudServiceImpl<IWmStartimageConfigDao, WmStartimageConfig> implements IWmStartimageConfigService{

	@QueryCache(keyPrefix="startimages")
	@Override
	public Map<String,Object> getStartImages() throws Exception {
		Map<String,Object> ret = new HashMap<String,Object>();
		List<WmStartimageConfig> configs = findList(new WmStartimageConfig());
		Map<String,Object> url = new HashMap<String,Object>();
		long timestamp = 0;
		for(WmStartimageConfig config : configs){
			url.put(config.getSizeType(), config.getImage());
			long configStamp = config.getModifyTime().getTime();
			if(configStamp > timestamp){
				timestamp = configStamp;
			}
		}
		ret.put("url", url);
		ret.put("timestamp", String.valueOf(timestamp));
		return ret;
	}

}